<?php
!defined('P_W') && exit('Forbidden');
require_once R_P.'lib/base/related.php';
class PW_HouseAreaRelated extends Related {
	function initRang($piece) {
		if ($this->ifLoop) return $this->ifLoopRang($piece);
		$options	= $this->_getAreaOptions();
		$piece['rang']	= str_replace('<option value="'.$piece['rang'].'">','<option value="'.$piece['rang'].'" selected>',$options);
		$piece['rang']	= '设置所属区域：'.'<select name="rang['.$piece['id'].']">'.$piece['rang'].'</select>';
		return $piece;
	}
	//TODO
	function childGetParamName($key) {
		$temp = array(
			'name'=>'楼盘名称',
			'aveprice'=>'价格',
			'area'=>'区域',
			'opendate'=>'开盘时间',
		);
		if (isset($temp[$key])) return  $temp[$key];
		return false;
	}
	
	function getPushHtml() {
		return '请输入要调用的楼盘hid:'.$this->_input;
	}
	
	function getInfoByKey($key,$param) {
		global $db;
		require(R_P.'lib/tplgetdata.class.php');
		House::loadClass('housesortelement','',false);
		$key	= (int) $key;
		if (!$key) return false;
		$element = new PW_HouseSortElement();
		
		$house = $element->getHouseInfo($key);
		$temp	= array();
		foreach ($param as $k=>$value) {
			if (array_key_exists($k,$house)) {
				$temp_2 = $house[$k];
			} else {
				$temp_2 = '';
			}
			$temp[$k]	= PW_tplGetData::_analyseResultByParameter($temp_2,$value);
		}
		return $temp;
	}
	
	function _getAreaOptions() {
		global $house_field;
		
		$options = '<option value=""></option>';
		foreach ($house_field['area'] as $key => $area) {
			$options .= '<option value="'.$key.'">'.$area['name'].'</option>';
		}
		
		return $options;
	}
}
?>